<?php

namespace App\Admin\Actions\Grid;

use App\Admin\Renderable\DetailRenderable;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Route;


class Detail extends RowAction
{
    /**
     * @return string
     */
    protected $title = '详情';

    public function render(): string|Modal
    {
        // 实例化表单类并传递自定义参数
        $show = DetailRenderable::make(['id' => $this->getKey(), 'controller' => Arr::first(explode('@', Route::current()->getActionName()))]);

        return Modal::make()
            ->lg()
            ->body($show)
            ->button('<a href="javascript:void(0)"><i class="feather icon-eye"> ' . $this->title . '</i></a>');
    }
}
